﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using BbsbWebService.Classes;
using System.Windows;

namespace BbsbWsGui
{
    public class StateTemplateSelector : DataTemplateSelector
    {
        public DataTemplate PowerOnTemplate { get; set; }
        public DataTemplate PowerOffTemplate { get; set; }
        public DataTemplate PowerUnknownTemplate { get; set; }

        public override System.Windows.DataTemplate SelectTemplate(object item, System.Windows.DependencyObject container)
        {
            var stateItem = item as StateItem;
            if (stateItem == null)
                return base.SelectTemplate(item, container);

            if (stateItem.State == BbsbWebService.Enums.PowerState.On)
            {
                return PowerOnTemplate;
            }
            else if (stateItem.State == BbsbWebService.Enums.PowerState.Off)
            {
                return PowerOffTemplate;
            }

            return PowerUnknownTemplate;
        }
    }
}
